//首页全局数据

//导入创建切片的方法
import {createSlice} from '@reduxjs/toolkit'

//创建切片
const homeSlice=createSlice({
    name:'home',//定义切片名称
    initialState:{  
        //全局初始数据
        proList:[],
        bannerList:[]
    },
    //修改方法
    reducers:{
        changeProList(state,actions){
            state.proList=actions.payload
        },
        changeBannerList(state,actions){
            state.bannerList=actions.payload
        }
    }
})

//导出两个修改函数，方便调用
export const {changeProList,changeBannerList}=homeSlice.actions
//相当于
// const actions = homeSlice.actions;
// export const changeProList = actions.changeProList;
// export const changeBannerList = actions.changeBannerList;
//导出切片reducer
export default homeSlice.reducer